package android.funtionality;

import java.util.*;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;


public class FuncionesUsuario {
	JsonParser parser;
	static String URL = "http://alertatics.comule.com/api.php";

	
	public FuncionesUsuario(){
		parser = new JsonParser();
	}
	
	
	public JSONObject validateUser (String numero_telefonico, String password_hasheado, String pais, String token){
		
		List<NameValuePair> parametros = new ArrayList<NameValuePair>();
		
		parametros.add(new BasicNameValuePair("USR", numero_telefonico));
		parametros.add(new BasicNameValuePair("HASH", password_hasheado));
		parametros.add(new BasicNameValuePair("PAIS", pais));
		parametros.add(new BasicNameValuePair("TOKEN", token));
		parametros.add(new BasicNameValuePair("OP", "login"));
		
		JSONObject json = parser.obtenerJSONdeURL(URL, parametros);
		
		return json;
	}
	
	public JSONObject sentAlertaTics (String usrCode, String token){
		
		List<NameValuePair> parametros = new ArrayList<NameValuePair>();
		
		parametros.add(new BasicNameValuePair("USRCODE", usrCode));
		parametros.add(new BasicNameValuePair("TOKEN", token));
		parametros.add(new BasicNameValuePair("OP", "help"));
		
		JSONObject json = parser.obtenerJSONdeURL(URL, parametros);
		
		return json;
	}
	
	public JSONObject getLinkedUsers (String usrCode, String token){
		
		List<NameValuePair> parametros = new ArrayList<NameValuePair>();
		
		parametros.add(new BasicNameValuePair("USRCODE" , usrCode));
		parametros.add(new BasicNameValuePair("TOKEN", token));
		parametros.add(new BasicNameValuePair("OP", "linkedUsers"));
		
		JSONObject json = parser.obtenerJSONdeURL(URL, parametros);
		
		return json;
	}
	
}
